# Makefile for tiff2png
# Copyright 1996 Willem van Schaik
# Copyright 2002 Greg Roelofs

#CC=cc
CC=gcc
OPTIMFLAGS = -O3 
DEBUGFLAGS = -g -Wall -W
#COPY=cp
COPY=/bin/cp -p
DEL=/bin/rm -f

# TAKE CARE:  If you use the (very old) libtiff that comes with netpbm, which
#             is v2.4, you may need to change this to -DOLD_LIBTIFF.  (The
#             only difference is whether tiffcomp.h is included; it is not
#             installed by default in newer versions of libtiff, but it may
#             have been required for older versions.)
#TIFF_VERSION = -DOLD_LIBTIFF
TIFF_VERSION =

# It appears that PHOTOMETRIC_MINISWHITE should always be inverted (which
# makes sense), but if you find a class of TIFFs or a version of libtiff for
# which that is *not* the case, try not defining INVERT_MINISWHITE.
#
# FAXPECT is a custom conversion option for 2:1 stretched faxes. [GRR 19990713]
#
# DEFAULT_DESTDIR_IS_CURDIR will put all converted images into the current
# directory (.) if the -destdir option is given without an argument.
#
OPTION_FLAGS = -DINVERT_MINISWHITE -DFAXPECT -DDEFAULT_DESTDIR_IS_CURDIR


# change to match your directories (you see the ./ and ../ ?!?!)
#LIBTIFF=/usr/lib
LIBTIFF=/usr/local/lib
#LIBTIFF=../libtiff/libtiff
#LIBTIFF=../libgr2/tiff/libtiff
#LIBTIFF=../netpbm/libtiff
TIFFINC=/usr/local/include
#TIFFINC=$(LIBTIFF)

# newer libtiffs (can) use libjpeg, too
LIBJPEG=/usr/lib
#LIBJPEG=/usr/local/lib
#LIBJPEG=../libjpeg
#LIBJPEG=../libgr2/jpeg

#LIBPNG=/usr/lib
#LIBPNG=/usr/local/lib
LIBPNG=../libpng
#LIBPNG=../libgr2/png
#PNGINC=/usr/local/include
PNGINC=$(LIBPNG)

#ZLIB=/usr/lib
#ZLIB=/usr/local/lib
ZLIB=../zlib
#ZINC=/usr/local/include
ZINC=$(ZLIB)

INSTALL=/usr/local

CFLAGS=$(TIFF_VERSION) $(OPTION_FLAGS) $(OPTIMFLAGS) $(DEBUGFLAGS) \
	-I$(TIFFINC) \
	-I$(PNGINC) \
	-I$(ZINC)
LDFLAGS=-L. \
	-L$(LIBTIFF) -ltiff \
	-L$(LIBJPEG) -ljpeg \
	-L$(LIBPNG) -lpng \
	-L$(ZLIB) -lz \
	-lm
SLDFLAGS=-L. \
	$(LIBTIFF)/libtiff.a \
	$(LIBJPEG)/libjpeg.a \
	$(LIBPNG)/libpng.a \
	$(ZLIB)/libz.a \
	-lm

OBJS = tiff2png.o

# default is dynamic only (or mixed dynamic/static, depending on installed libs)
default: tiff2png

# it's nice to have a choice, though
all: tiff2png tiff2png-static

tiff2png: tiff2png.o
	$(CC) -o tiff2png tiff2png.o $(LDFLAGS)

tiff2png-static: tiff2png.o
	$(CC) -o tiff2png-static tiff2png.o $(SLDFLAGS)

install: all
	$(COPY) tiff2png $(INSTALL)/bin
#	$(COPY) tiff2png.1 $(INSTALL)/man/man1

clean:
	$(DEL) *.o tiff2png tiff2png-static

# leave this line empty

$(OBJS):
